import fiveagon.io.*;
//import processing.dxf.*;
//import processing.opengl.*;
import processing.pdf.*;

//String savePrefix = "print/basic-saver";
String savePrefix = "basic-saver"; // in effect, equal to above

Saver saver2D = new Saver2D(this, savePrefix);
//Saver saver3D = new Saver3D(this, savePrefix);
//Saver saverDXF = new SaverDXF(this, savePrefix);

Saver toggleSaver2D = new ToggleSaver(new Saver2D(this, "toggle-saver"));

//Saver saver = saver2D;
Saver saver = toggleSaver2D;

float circleSize;
color bgColor = color(0);

void setup()
{
    size(300, 300);
    smooth();
    noLoop();    // redraw() in mouseMoved()
    println(saver);
    background(bgColor);
    circleSize = height/6;
}

void draw()
{
    saver.beginRecord();

    // Comment background() out for ToggleSaver!
    //    background(bgColor);    

    // Ohhh, what's the algorhythm here? =)
    // trigonometry
    ellipse(mouseX, mouseY, circleSize, circleSize);
    ellipse(width - mouseX, height - mouseY, circleSize/2, circleSize/2);
    ellipse(width - mouseY, height - mouseX, circleSize/3, circleSize/3);
    ellipse(0 + mouseY, 0 + mouseX, circleSize/4, circleSize/4);

    saver.endRecord();
}

void keyTyped() {
    switch(key) {
    case ' ':
    case 'l':
        background(bgColor);
        break;
    case 'o':
        saver.save();
        break;
    case 'p':
        saver.saveRecord();
        break;
    case 'P':
        saver.save();
        saver.saveRecord();
        break;
    }
    redraw();
}

void mouseMoved() {
    redraw();
}

